<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.List,nc.vo.bd.material.marbasclass.MarBasClassVO"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path =request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>下拉列表</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script src="<%=path %>/js/jquery-1.4.4.js" type="text/javascript"></script>
		<link href="<%=path%>/css/main.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/dialog.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css" />
		<script language="javascript" type="text/javascript" src="<%=path%>/calendar/WdatePicker.js"></script>
		<script language="JavaScript" type="text/javascript" src="<%=path%>/js/caltimer.js"></script>
	
	</head>

	<body>
		<div style="ovoverflow-y:scroll;width:100%;height:100%">
		<p>产品分类信息</p>
		<table  border="0" cellspacing="0" class="subpage_table1 withborder2">
			<tr>
				<th width="50"  align="center">选择</th>
				<th width="100"  align="center">编码</th>
				<th width="100" align="center">名称</th> 
			</tr>
			<c:if test="${prdClsList!=null}">
				<c:forEach items="${prdClsList}" var="prodCls" varStatus="index">
					<tr align="center">
					<td>
						<input name="check1" type="checkbox" />
						<input name="pkmarCl1" type="hidden" value="${prodCls.pk_marbasclass}"/>
					</td>
					<td><input name="code1" type="text" class="list_text_1"  value="${prodCls.code}" /></td>
					<td><input name="name1" type="text" class="list_text_2"  value="${prodCls.name}" /></td>
					 
				</c:forEach>
			</c:if>
		</table>
		<p></p>
		<div align="center">
			<input type="button" class="buttonok" value="确定" onclick="javascript: choose1();"/>
				&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" class="buttoncan" value="关闭" onclick="clearvalue()"/>
		</div>
		</div>
		
		<script type="text/javascript">
		function choose1() {
			var objs = document.getElementsByName("check1");
			if(objs.length>0){
				var codes=document.getElementsByName("code1");
				var names=document.getElementsByName("name1");
				var pkmarClss=document.getElementsByName("pkmarCl1");
				
				for(var i=0;i<objs.length; i=i+1){	
					if(objs[i].checked){
						var code=codes[i].value;
						var name=names[i].value;
						var pkmarCls=pkmarClss[i].value;
						//如果不存在产品分类，则添加
						if(!isExistCl(pkmarCls)){
							addProdClInfo(code,name,pkmarCls);
						}else{
							alert("编码为'"+code+"'的产品分类已添加");
							return ;
						}
					}
				}
			}
			parent.hideMe();
		}
		//检查是否已存在选择的分类
		function isExistCl(pkmarCl){
			var flag=false;
			if(pkmarCl!=null){
				var pkProdCls=parent.document.getElementsByName("pkProdCl");
				if(pkProdCls!=null && pkProdCls.length>0){
					for(var i=0;i<pkProdCls.length;i++){
						if(pkmarCl==pkProdCls[i].value){
							flag=true;
							break;
						}
					}	
				}
			}
			return flag;
		}
		
		function clearvalue(){
			parent.hideMe();
		}
		
		function addProdClInfo(code,name,pkmarCl) {
			var prodList = parent.document.all("prodList");
			if(prodList != null) {
		 		var row = prodList.insertRow();
		 		var rows = prodList.rows;
				row.id=pkmarCl;
				//序号
				var cell = row.insertCell()
				cell.align = 'center';
				cell.innerHTML = rows.length-1;
				
				//名称	
		 		cell = row.insertCell()
		 		cell.align = 'center';
		 		cell.innerHTML = "<input type='text' id='"+pkmarCl+"-name' class='list_text_2' name='name' value='"+name+"' readOnly/>";
				 	
		 	    //用途
		 		cell = row.insertCell()
		 		cell.align = 'center';
		 		cell.innerHTML = "<input type='text' id='prod_app' class='list_text_2' name='prod_app' value='' />";
		 	    
		 	    //产能
		 		cell = row.insertCell()
		 		cell.align = 'center';
		 		cell.innerHTML = "<input type='text' id='prod_output' class='list_text_2' name='prod_output' value='' />";
		 	  
		 	    //主要材料来源
		 		cell = row.insertCell()
		 		cell.align = 'center';
		 		cell.innerHTML = "<input type='text' id='prod_material' class='list_text_2' name='prod_material' value='' />";

		 	    //供货周期
		 		cell = row.insertCell()
		 		cell.align = 'center';
		 		cell.innerHTML = "<input type='text' id='prod_cycle' class='list_text_2' name='prod_cycle' value='' />";
		 	 
		 	    //备注（请补充注明：市场占有率、主要客户级业绩、可供余量、主要设备、可信竞争力）
		 		cell = row.insertCell()
		 		cell.align = 'center';
		 		cell.innerHTML = "<input type='text' id='prod_memo' class='list_text_2' name='prod_memo' value='' />";
		 		
		 		//删除
		 		cell = row.insertCell();
		 		cell.align = 'center';
		 		cell.innerHTML = "<a href=\"javascript:deleteRowById('"+pkmarCl+"')\" class=\"linkstyle3\">删除</a> <input type='hidden' name='pkProdCl' value='"+pkmarCl+"' />";
		 	}
		}
		
		function getstatuHtml(pkmarCl){
			return innerHtml="<select name='status' id='"+pkmarCl+"-status' ><option value=''>---请选择---</option><option value='1'>合格</option><option value='2' >不合格</option><option value='3' >潜在</option></select>"
		}
	</script>
	</body>
</html>
